package context

import "github.com/gookit/validate"

type RegContext struct {
	Telephone string `validate:"required|cnMobile" json:"telephone"`          // 注册手机
	Password  string `validate:"required|minLen:6|maxLen:16" json:"password"` // 密码
	PhoneCode int    `validate:"required|len:6|int" json:"phoneCode"`         // 短信验证码
}

// Messages 您可以自定义验证器错误消息
func (f RegContext) Messages() map[string]string {
	return validate.MS{
		"required":           "{field}不能为空",
		"Password.minLen":    "{field}不能少于%d位",
		"Password.maxLen":    "{field}最大不能超过%d位",
		"Telephone.cnMobile": "{field}输入不合法",
		"PhoneCode.len":      "{field}长度必须是%d位",
		"PhoneCode.int":      "{field}必须是数字",
	}
}

// Translates 你可以自定义字段翻译
func (f RegContext) Translates() map[string]string {
	return validate.MS{
		"Telephone": "用户手机",
		"Password":  "用户密码",
		"PhoneCode": "手机短信码",
	}
}
